package net.bitacademy.java23.service;

import java.util.List;

import javax.annotation.Resource;

import net.bitacademy.java23.dao.RouteDao;
import net.bitacademy.java23.vo.Route;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Service;

@Service("routeService")
public class DefaultRouteService implements RouteService {
	//private RoutePhotoDao RoutePhotoDao;
	private RouteDao routeDao;
	
	@Required
	@Resource
	public void setRouteDao(RouteDao routeDao) {
		this.routeDao = routeDao;
	}
	
	/*
	@Required
	@Resource
	public void setRoutePhotoDao(RoutePhotoDao routePhotoDao) {
		this.routePhotoDao = routePhotoDao;
	}
	*/

	@Override
	public List<Route> listRoute() {
		return routeDao.selectRouteList();
	}

	
	@Override
	public void addRoute(Route route) {
		routeDao.insertRoute(route);
	}



	@Override
	public Route getRoute(int routeNo) {
		Route route = routeDao.selectRoute(routeNo);
		//route.setPhotoList( routePhotoDao.selectRoutePhotoList(routeNo));
		return route;
	}
/*
	@Override
	public void modifyRoute(Route route) {
		routePhotoDao.deleteRoutePhoto(route.getRouteNo());
		routeDao.updateRoute(route);
		Photo photo = null;
		for (int i = 0; i < route.getPhotoList().size(); i++) {
			photo = route.getPhotoList().get(i);
			photo.setRouteNo(route.getRouteNo());
			routePhotoDao.insertRoutePhoto(photo);
		}
	}
*/
	@Override
	public void removeRoute(int routeNo) {
		routeDao.deleteRoute(routeNo);
	}

}
